﻿using System;
using System.Collections.Generic;
using System.Text;

namespace daSyntaxAnalyser.SyntaxTree
{
    using daBase.Objects;

    public class ArrayTypeElement : SyntaxTreeElement, ITypeElement
    {
        private IntervalsVariableExpressionElement intervals;
        private ITypeElement type;

        public IntervalsVariableExpressionElement Intervals { get { return intervals; } set { intervals = value; } }
        public ITypeElement Type { get { return type; } set { type = value; } }

        public ArrayTypeElement(TokenInfo StartInfo, IntervalsVariableExpressionElement Intervals, ITypeElement Type, List<TokenInfo> Comments)
            : base(StartInfo, Comments)
        {
            intervals = Intervals;
            type = Type;
        }

        public override string ToString()
        {
            string result = "array ";
            if (intervals != null) result += string.Format("{0} ", intervals);
            return string.Format("{0} of {1}", result, type);
        }

        protected override IEnumerator<ISyntaxTreeElement> CreateEnumerator()
        {
            if (intervals != null)
                yield return intervals;
            yield return type;
        }
    }
}
